package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.view.View;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.bean.TrackBean;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;

/**
 * Created by yidong on 2017/8/3.
 */

public class TrackListAdapter extends CommonAdapter<TrackBean> {
    private OrderListener listener;
    private String str;

    public void setBtnStr(String str1) {
        str = str1;
    }

    public TrackListAdapter(Context context, int layoutId, List<TrackBean> datas) {
        super(context, layoutId, datas);
    }

    public void setListener(OrderListener orderListener) {
        listener = orderListener;
    }

    @Override
    protected void convertView(ViewHolder holder, TrackBean trackBean, final int position) {
        holder.setText(R.id.cc_name, trackBean.getTou_name() + "(订单号" + trackBean.getDispatch_id() + ")");
        holder.setText(R.id.tour_level, trackBean.getTour_level());
        holder.setText(R.id.tv_car_name, trackBean.getTitle());
        holder.setText(R.id.tv_client_name, trackBean.getDealer_name());
        holder.setText(R.id.tv_dealer_address, trackBean.getDealer_address());
        holder.setText(R.id.tv_car_id, trackBean.getCar_id());
        holder.setText(R.id.tv_reservation_time, trackBean.getDispatch_time());
        holder.setText(R.id.tv_sure_order, str);
//        if (trackBean.getDispatch_status() != null) {
//            holder.setVisible(R.id.tv_sure_order, false);
//        } else {
//            holder.setVisible(R.id.tv_sure_order, true);
//        }
        if(str.equals("自建订单") ||str.equals("确认接单")){
            holder.setVisible(R.id.tv_sure_order,false);
        }else {
            holder.setVisible(R.id.tv_sure_order, true);
        }
        holder.setOnClickListener(R.id.tv_sure_order, new View.OnClickListener() {//调价
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.acceptOrder(mDatas.get(position).getDispatch_id());
                }
            }
        });
    }

    public interface OrderListener {
        void acceptOrder(String dispatch_id);
    }

}
